package y_2025.m04.d11.t1;

public class InstrumentTest {
    public static void main(String[] args) {
        Piano piano = new Piano();
        Violin violin = new Violin();
        Cello cello = new Cello();
         testPlay(piano);
         testPlay(violin);
         testPlay(cello);
    }

    public static void testPlay(Instrument instrument) {
        instrument.play();
    }
}


abstract class Instrument {
    abstract void play();
}

class Violin extends Instrument{
    @Override
    void play() {
        System.out.println("弹小提琴");
    }
}

class Cello extends Instrument{
    @Override
    void play() {
        System.out.println("谈大提琴");
    }
}
class Piano extends Instrument {
    @Override
    void play() {
        System.out.println("弹钢琴");
    }
}
